<?php

/**
 * 后台首页控制器
 * @author:Cloud
 * @copyright:TcitCMS
 * @since:2014-05-12
 */

namespace Admin\Controller;

class AreaSelectController extends CommonController {

    function province() {
        $model = M('province');
        $data = $model->select();
        $this->ajaxReturn($data);
    }

    function city() {
        $id = I('post.id', '', 'int');
        $model = M('city');
        $data = $model->where('`provinceid`=' . $id)->select();
        $this->ajaxReturn($data);
    }

    function area() {
        $id = I('post.id', '', 'int');
        $model = M('area');
        $data = $model->where('`cityid`=' . $id)->select();
        $this->ajaxReturn($data);
    }

    function selected() {
        $model1 = M('province');
        $model2 = M('city');
        $model3 = M('area');
        $Action = I('post.Action', '', 'trim');
        $ProvinceId = I('post.ProvinceId', '', 'trim');
        $CityId = I('post.CityId', '', 'trim');
        if ($Action == 'GetProvince') {
            $data = $model1->select();
            $this->ajaxReturn(
                    array('STATUS' => 'SUCCESS', 'DATA' => $data)
            );
        } elseif ($Action == 'GetCity') {
            $data = $model2->where('`provinceid`=' . $ProvinceId)->select();
            $this->ajaxReturn(
                    array('STATUS' => 'SUCCESS', 'DATA' => $data)
            );
        } elseif ($Action = 'GetArea') {
            $data = $model3->where('`cityid`=' . $CityId)->select();
            $this->ajaxReturn(
                    array('STATUS' => 'SUCCESS', 'DATA' => $data)
            );
        } else {
            $this->ajaxReturn(FALSE);
        }
    }

}

?>